import {fetchDetailById, antistopReplyList,antistopAlter,antistopSave,antistopDelete,dictionaryList,dictionaryCertification } from '@/services/knowledgemanagement';

export default {
  namespace:'antistopReply',

  state: {

  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(antistopReplyList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) {
      const response = yield call(antistopAlter, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) {
      const response = yield call(antistopSave, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchd({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(antistopDelete, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetche({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(dictionaryList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchf({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(dictionaryCertification, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchDetail({ payload, callback }, { call, put }) { // 个性化词典
      const response = yield call(fetchDetailById, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    }
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {

      };
    },
  },
};
